package LN.Alquileres;

import LN.Persona.Visitante.Visitante;
import LN.Varios.Hosteria;
import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import org.hibernate.envers.Audited;

@Audited
@Entity
public class Hospedaje_Salon extends Hospedaje implements Serializable {

    @ManyToOne
    private Salon elSalon;
    @ManyToOne
    private Tarifa_Salon servicio;

    public Hospedaje_Salon() {
    }

    public Hospedaje_Salon(Salon elSalon, Tarifa_Salon servicio, Visitante unVisitante, Date ingreso, Date egreso, double descuento) {
        super(unVisitante, ingreso, egreso, descuento);
        this.elSalon = elSalon;
        this.servicio = servicio;
        Hosteria.persistencia.insert(this);
    }

    public Salon getElSalon() {
        return elSalon;
    }

    public void setElSalon(Salon elSalon) {
        this.elSalon = elSalon;
    }

    public Tarifa_Salon getServicio() {
        return servicio;
    }

    public void setServicio(Tarifa_Salon servicio) {
        this.servicio = servicio;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Hospedaje_Salon)) {
            return false;
        }
        Hospedaje_Salon other = (Hospedaje_Salon) object;
        if ((this.getId() == null && other.getId() != null) || (this.getId() != null && !this.getId().equals(other.getId()))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.getServicio().getTipo();
    }

    public Object[] toVector() {
        Calendar in = Calendar.getInstance();
        in.setTime(this.getEgreso());
        int dia = in.get(Calendar.DAY_OF_MONTH);
        int mes = in.get(Calendar.MONTH);
        int anio = in.get(Calendar.YEAR);
        int hora = in.get(Calendar.HOUR);
        int minutos = in.get(Calendar.MINUTE);

        Object fila[] = {this, this.getUnVisitante().getApellido() + " " + this.getUnVisitante().getNombre(), this.getIngreso(), this.getEgreso(), this.getDescuento(), this.getServicio().getPrecio()};
        return fila;
    }
}
